<!---saves the image, overwriting the original.--->
<cfparam name="agreed" default="0">
<cfparam name="dosave" default="0">
<cfparam name="new_imagefile" default="none.jpb">
<cfparam name="dir" default="/">

<cfif NOT fileexists('#request.basepath#images#dir##new_imagefile#')>
	<cfset dosave = 1>
</cfif>

<cfif fileexists('#request.basepath#images#dir##form.new_imagefile#') AND agreed IS 0>
	<cfoutput>
	<script language="javascript">
    var agree=confirm("A file by that name (#new_imagefile#) already exists in that folder.  Do you want to overwrite it?");
    if (agree) {
        location.replace('index.cfm?c=imagelibrary&a=saveas&new_imagefile=#imagefile#&dir=#dir#&agreed=1'); 
        }
	</script>
	</cfoutput>    
    <cfset dosave = 0>
</cfif>

<cfif fileexists('#request.basepath#images#dir##new_imagefile#') AND agreed IS 1>
	<cfset dosave - 1>
</cfif>

<cfif dosave IS 1>
	<cffile action = "copy" source = "#request.basepath#images/temp/#cookie.imagefile#" destination="#request.basepath#images#dir##new_imagefile#" nameconflict="overwrite" mode="777">
    <cflocation url="index.cfm?c=imagelibrary&dir=#dir#">
</cfif>

<cfinclude template="../frm/edit.cfm">